package com.itxx.keyCase;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateDemo {
    public static void main(String[] args) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        //老版本日期转换
        //将Date转为String
        Date date = new Date();
        String format = sdf.format(date);
        System.out.println(format);
        //将String转为Date
        String s= "2020-11-11";
        Date parse = sdf.parse(s);
        System.out.println(parse.toString());

    }
}
